package com.Cychat.post.config;

import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.SimpleMessageConverter;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @Auther: 崔航
 * @Date: 2025/11/4:11:07
 * @Description:rabbitmq配置,序列化白名单
 */
@Configuration
public class RabbitConfig {
    @Bean
    public SimpleMessageConverter messageConverter() {
        SimpleMessageConverter converter = new SimpleMessageConverter();
        converter.setAllowedListPatterns(
                List.of("com.Cychat.post.entity.mq.*"));
        return converter;
    }

    @Bean
    @LoadBalanced // 添加负载均衡注解，支持服务发现
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}